<!DOCTYPE html PUBLIC "-//W3C//DTD XHTML 1.0 Transitional//EN" 
    "http://www.w3.org/TR/xhtml1/DTD/xhtml1-transitional.dtd">

<html xmlns="http://www.w3.org/1999/xhtml"
	xmlns:ui="http://java.sun.com/jsf/facelets"
	xmlns:h="http://java.sun.com/jsf/html"
	xmlns:f="http://java.sun.com/jsf/core"
	xmlns:p="http://primefaces.org/ui">

	

	<ui:composition template="/webApp/layout/template.xhtml">		
		<ui:define name="conteudo">
			<f:loadBundle var="cadastroMsg" basename="nls.cadastroUsuario"></f:loadBundle>	
			
			<h:outputScript library="js" name="functions.js" target="head" />

			<h:form prependId="false">
				<p:growl id="messages" globalOnly="false" showDetail="false" sticky="false" life="830" />
				<h:panelGrid>

					<h:panelGrid id="grid" columns="2">
						<f:facet name="header">
							<p:outputLabel value="#{cadastroMsg.userAccount}" />
						</f:facet>

						<p:outputLabel value="#{cadastroMsg.name}:"  />
						<p:inputText value="#{usuarioBean.usuario.nome}"  required="true" requiredMessage="#{cadastroMsg.phraseName}"/>

						<p:outputLabel value="#{cadastroMsg.lastName}:" />
						<p:inputText value="#{usuarioBean.usuario.sobrenome}" required="true" requiredMessage="#{cadastroMsg.phraseLastName}"/>

						<p:outputLabel value="#{cadastroMsg.identificationDocument}:" />
						<p:inputMask mask="99.999.999-9" value="#{usuarioBean.usuario.rg}" required="true" requiredMessage="#{cadastroMsg.phraseRG}"/>
						
						<p:outputLabel value="#{cadastroMsg.cpf}:" />
						<p:inputMask mask="999.999.999-9" value="#{usuarioBean.usuario.cpf}" required="true" requiredMessage="#{cadastroMsg.phraseCPF}"/>
						


						<p:outputLabel value="#{cadastroMsg.login}:" />
						<p:inputText value="#{usuarioBean.usuario.login}" required="true" requiredMessage="#{cadastroMsg.phraseLogin}"/>

						<p:outputLabel value="#{cadastroMsg.email}:" />
						<p:inputText value="#{usuarioBean.usuario.email}">
							<p:ajax event="blur" listener="#{usuarioBean.validarEmail}"
								update="messages" />
						</p:inputText>

						<p:outputLabel for="senhaUsuario" value="#{cadastroMsg.password}:" />
						<p:password id="senhaUsuario" value="#{usuarioBean.usuario.senha}"
							feedback="true" placeholder="#{cadastroMsg.enterPassword}:" inline="true"
							weakLabel="#{cadastroMsg.passwordWeak}" goodLabel="#{cadastroMsg.passwordMedium}"
							strongLabel="#{cadastroMsg.passwordStrong}" promptLabel="#{cadastroMsg.enterPassword}" required="true" requiredMessage="#{cadastroMsg.phrasePassword}">
						</p:password>


						<p:outputLabel for="confirmarSenhaUsuario" value="#{cadastroMsg.confirmPassword}:" />
						<p:password id="confirmarSenhaUsuario" styleClass="round full-width-input"
							 value="#{usuarioBean.usuario.confirmaSenha}" required="true">
						</p:password>

						<p:outputLabel value="#{cadastroMsg.profile}:" />
						<p:selectOneMenu value="#{usuarioBean.perfil}">
							<f:selectItem itemValue="Administrador" itemLabel="#{cadastroMsg.administrator}" />
							<f:selectItem itemValue="Funcionario" itemLabel="#{cadastroMsg.employee}" />
						</p:selectOneMenu>

					</h:panelGrid>
				</h:panelGrid>

				<p:commandButton value="#{cadastroMsg.register}"
				action="#{usuarioBean.cadastrarUsuario}" update="messages" />
			</h:form>
		</ui:define>
	</ui:composition>
</html>